<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
		<title>填写银行卡信息</title>
		<link rel="stylesheet" href="__PUBLIC__/Home/css/common.css">
		<link rel="stylesheet" href="__PUBLIC__/Home/css/main.css">
		<script src="__PUBLIC__/Home/js/zepto.js"></script>
		<script src="__PUBLIC__/Home/js/common.js"></script>
		<script src="__PUBLIC__/Home/js/delIOS_huitan.js"></script>
	</head>
	<body class="box">
		<!--提示文字-->
		<div class="tip" style="opacity: 0;z-index: -1"></div>
		<!--正文区域-->
		<div id="editKaTop" class="topBackTitle">
			<div class="contain maxWidth">
				<a class="hz back" href="__URL__/index">&#xe600;</a>填写银行卡信息
			</div>
		</div>
		<div id="editKaMain" class="fastscroll top50bot0">
			<div class="contain maxWidth">
				<ul class="ullist1line">
					<li>
						<a href="javascript:;">
							<div class="left">
								<span class="title">持卡人</span><input type="text" placeholder="请输入持卡人" id="name">
							</div>
						</a>
					</li>
					<li>
						<a href="javascript:;">
							<div class="left">
								<span class="title">卡号</span><input type="number" placeholder="请输入银行卡卡号" id="card_num">
							</div>
						</a>
					</li>
					<li>
						<!-- <a href="__URL__/seltype"> -->
						<a href="javascript:;" id="goSelectKaType">
							<div class="left">
								<span class="title">卡类型</span><span class="name kaname">{$typelist[0]['title']}</span>
								<input type="hidden" id="type_id" value="{$typelist[0]['id']}" />
							</div>
							<div class="right">
								<span class="hz">&#xe60c;</span>
							</div>
						</a>
					</li>
					<li>
						<a href="javascript:;">
							<div class="left">
								<span class="title">手机号码</span><input type="number" id="mobile" placeholder="请输入银行卡预留手机号">
							</div>
						</a>
					</li>
				</ul>
				<a href="javascript:;" class="orangeBtn">确认</a>
			</div>
		</div>

		<script>
			//返回按钮
			/*$('#editKaTop .back').on('tap',function(){
				window.history.go(-1);
			});*/

			$('.orangeBtn').on('tap',function(){
				var name=$('#name').val();
				var card_num=$('#card_num').val();
				var mobile=$('#mobile').val();
				if(!notEmpty(name)){
					tipFun('持卡人不为空');
					return false;
				}
				if(!notEmpty(card_num)){
					tipFun('卡号不为空');
					return false;
				}
				if(!notEmpty(mobile)){
					tipFun('手机号码不为空');
					return false;
				}
				if(!checkTel(mobile)){
					tipFun('请输入有效的手机号码');
					return false;
				}
				var type = "{$_GET['tx']}";
				$.ajax({
					type: "post",
					dataType: "json",
					url: "__URL__/saveBankinfo",
					data: {name:$('#name').val(),card_num:$('#card_num').val(),type_id:$('#type_id').val(),mobile:$('#mobile').val()},
					success: function(json){
						tipFun(json.info);
						var url = "";
						if(json.status>0){
							//setTimeout(function(){
								if(type==1){
									url = "{:U('/Member/Index/withdraw')}";
									//window.location.href = "{:U('/Member/Index/withdraw')}";
								}else{
									url = "__URL__/index";
									//window.location.href='__URL__/index';
								}
								location.href = url;
							//},1200);
						}
					}
				})
			});

			//点击确认
			$('#editKaMain .orangeBtn').on('tap',function(){
				location.href='我的账户余额提现2选择卡类型.html';
			});

			//tip
			function tipFun(str){
				$('.tip').text(str).css({
					'opacity':'1',
					'z-index':'9999'
				});
				setTimeout(function(){
					$('.tip').css('opacity','0');
					setTimeout(function(){
						$('.tip').css('z-index','-1');
					},300);
				},1300);
			}

			//判断当前页面是正常进入，还是选择了卡类型跳回的
			//给卡姓名 和卡号赋值
			/*var hrefstr=location.href;
			if(hrefstr.indexOf('name=')!=-1){
				var name=hrefstr.substring(hrefstr.indexOf('name=')+5,hrefstr.indexOf('/num='));
				var num=hrefstr.substring(hrefstr.indexOf('num=')+4,hrefstr.indexOf('/mobile='));
				var mobile=hrefstr.substring(hrefstr.indexOf('mobile=')+7);
				if(name!="null"){
					$('#name').val(name);
				}
				if(num!="null"){
					$('#card_num').val(num);
				}
				if(mobile!="null"){
					$('#mobile').val(mobile);
				}
			}*/
			var aname = "{$_GET['name']}", anum = "{$_GET['num']}", atel = "{$_GET['mobile']}";
			if(aname!="") $('#name').val(aname);
			if(anum!="")$('#card_num').val(anum);
			if(atel!="")$('#mobile').val(atel);

			//跳转到选择卡类型页面 index.php?s=/Member/Bank/seltype
			$('#goSelectKaType').on('click',function(){
				var name = $('#name').val();
				var card_num = $('#card_num').val();
				var mobile = $('#mobile').val();
				var type = "{$_GET['tx']}";
				var url = "{:U('Bank/seltype')}";
				if(name!=""){
					url += "&name="+name;
				}
				if(card_num!=""){
					url += "&num="+card_num;
				}
				if(mobile!=""){
					url += "&mobile="+mobile;
				}
				if(type!=""){
					url +="&tx="+type;
				}
				/*if(name==''){
					name=null;
				}
				if(card_num==''){
					card_num=null;
				}
				if(mobile==''){
					mobile=null;
				}*/
				location.href = url;
				//location.href='/index.php?s=/Member/Bank/seltype/name='+name+'/num='+card_num+'/mobile='+mobile;
				
			});
		</script>
	</body>
</html>
